package com.jxc.summer.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.jxc.summer.dao.QualityMapper;
import com.jxc.summer.service.QualityService;

@Service
public class QualityServiceImpl implements QualityService {

	@Autowired
	private QualityMapper qualityMapper;
	
	@Transactional(propagation=Propagation.REQUIRED, isolation=Isolation.READ_COMMITTED, readOnly=true)
	@Override
	public Map<String, Object> pageList(Map<String, Object> params) {
		List<Map<String, Object>> list = qualityMapper.pageList(params);
		int count = qualityMapper.pageListCount(params);
		// package result
		Map<String, Object> maps = new HashMap<String, Object>();
		maps.put("recordsTotal", count);		// 总记录数
		maps.put("recordsFiltered", count);	// 过滤后的总记录数
		maps.put("data", list); 
		return maps;
	}

	@Transactional(propagation=Propagation.REQUIRED, isolation=Isolation.READ_COMMITTED)
	@Override
	public int add(Map<String, Object> params) {
		int result = qualityMapper.add(params);
		return result;
	}

	@Transactional(propagation=Propagation.REQUIRED, isolation=Isolation.READ_COMMITTED)
	@Override
	public int update(Map<String, Object> params) {
		int result = qualityMapper.update(params);
		return result;
	}

	@Transactional(propagation=Propagation.REQUIRED, isolation=Isolation.READ_COMMITTED)
	@Override
	public int delete(Map<String, Object> params) {
		int result = qualityMapper.delete(params);
		return result;
	}

	@Override
	public List<String> getQuality(String companyCode) {
		return qualityMapper.getQuality(companyCode);
	}

}
